package com.wl.cloud.system.security.model;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author: wanglin
 * @date: 2023-09-18 周一
 * @Version: 1.0
 * @Description:
 */
@Data
@EqualsAndHashCode(of = "id")
@MappedSuperclass
public abstract class AbstractBaseSecurityModel implements Serializable {
    @Id
    @Column(columnDefinition = "varchar(50) comment '记录ID'")
    @TableId(type = IdType.ASSIGN_ID)
    private String id;
    @JsonFormat(shape = JsonFormat.Shape.NUMBER)
    @Column(columnDefinition = "datetime not null comment '创建时间'")
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime createTime;
    @JsonFormat(shape = JsonFormat.Shape.NUMBER)
    @Column(columnDefinition = "datetime not null comment '修改时间'")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    @Column(columnDefinition = "varchar(30) comment '创建人'")
    private String createBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Column(columnDefinition = "varchar(30) comment '修改人'")
    private String updateBy;

    /**
     * 只要有一个为false，就不可用用
     */
    @Column(columnDefinition = "bit default 1 comment  '是否可用,true:正常,false:禁用'")
    private Boolean isEnabled;
    @Column(columnDefinition = "bit default 1 comment  '账号是否失效,true:正常,false:禁用'")
    private Boolean isAccountNonExpired;
    @Column(columnDefinition = "bit default 1 comment  '密码是否失效,true:正常,false:禁用'")
    private Boolean isAccountNonLocked;
    @Column(columnDefinition = "bit default 1 comment  '账户是否锁定,true:正常,false:禁用'")
    private Boolean isCredentialsNonExpired;
}
